import { http } from '@/utils/http';
import type { LoginResult } from '@/types/auth';
import type { AnyObj } from '@/types/global';
import { useAuthStore } from '@/stores';
import { isLogin, getWxUserId, getWxOpenId, getLawFirmId } from '@/utils/auth';
import type { AnyObj } from '@/types/global';
const appId = import.meta.env.VITE_APP_ID;
const clientId = import.meta.env.VITE_CLIENT_ID;
const grantType = 'miniapp';


export const getLawfirmList = (data : AnyObj) => {
	const lawFirmId = getLawFirmId();
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/lawfirm/list`,
		data: {
			...data,
			// lawFirmId
		}
	});
}


export const getLawyerListByLawFirmId = (lawFirmId : string) => {
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/lawfirm/listLawyer/${lawFirmId}`,
	});
}

export const getLawfirmDetail = (lawFirmId : string) => {
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/lawfirm/${lawFirmId}`,
	});
}


export const getLawfirmCaseList = (lawFirmId : string) => {
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/lawfirm/listCase/${lawFirmId}`,
	});
}

export const getLawfirmAwardList = (lawFirmId : string) => {
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/lawfirm/listAward/${lawFirmId}`,
	});
}

export const getLawyerListOfLaw = (lawFirmId : string) => {
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/lawfirm/listLawyer/${lawFirmId}`,
	});
}


export const saveArchive = (data : AnyObj) => {
	return http<AnyObj[]>({
		method: 'POST',
		url: `/wx/lawfirm/saveArchive`,
		data
	});
}

export const getCase = (id : string) => {
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/lawfirm/case/${id}`,
	});
}

export const saveCase = (data : AnyObj) => {
	return http({
		method: 'POST',
		url: `/wx/lawfirm/saveCase`,
		data
	});
}

/**
 * 删除案例 
 * ids  1,2,3
 */
export const deleteCase = (ids : string) => {
	return http({
		method: 'DELETE',
		url: `/wx/lawfirm/case/${ids}`,
	});
}


export const saveLawyer = (data : AnyObj) => {
	return http({
		method: 'POST',
		url: `/wx/lawfirm/saveLawyer`,
		data
	});
}

export const getLawyerDetailById = (id : string) => {
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/lawfirm/lawyer/${id}`,
	});
}

export const deleteLawyer = (ids : string) => {
	return http({
		method: 'DELETE',
		url: `/wx/lawfirm/lawyer/${ids}`,
	});
}

export const getHonor = (id : string) => {
	return http({
		method: 'GET',
		url: `/wx/lawfirm/award/${id}`,
	});
}

export const saveHonor = (data : AnyObj) => {
	return http({
		method: 'POST',
		url: `/wx/lawfirm/saveAward`,
		data
	});
}

export const getHonorList = (lawFirmId : string) => {
	return http<AnyObj>({
		method: 'GET',
		url: `/wx/lawfirm/listAward/${lawFirmId}`,
	});
}

export const deleteHonor = (ids : string) => {
	return http({
		method: 'DELETE',
		url: `/wx/lawfirm/award/${ids}`,
	});
}

export const getRankList = () => {
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/lawfirm/listRank`,
	});
}

export const getLawfirmExpertiseList = () => {
	return http<AnyObj[]>({
		method: 'GET',
		url: `/wx/lawfirm/listExpertise`,
	});
}
